package cn.bsb.dao;
 

import java.util.Date; 
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.bsb.pojo.Article;
import cn.bsb.pojo.Recommend;
import tk.mybatis.mapper.common.Mapper;

public interface RecommendMapper extends Mapper<Recommend> {

	
	//以推荐文章列表
	@Select("SELECT * FROM article  WHERE recommend not in (0) ORDER BY `look` DESC")
	public List<Article> recommendList();
	//查询后的文章列表
	@Select("SELECT * FROM article WHERE recommend NOT IN (0) AND title LIKE CONCAT('%',#{title},'%') ORDER BY `look` DESC ")
	public List<Article> reSelectList(@Param("title") String title);
	
	//推荐文章列表
	@Select("SELECT * FROM article  WHERE recommend not in (1) ORDER BY `lik` DESC")
	public List<Article> goodList();
	//查询后的文章列表
	@Select("SELECT * FROM article WHERE recommend NOT IN (1) AND title LIKE CONCAT('%',#{title},'%') ORDER BY `lik` DESC ")
	public List<Article> reTitleList(@Param("title") String title);
	
	//取消推荐文章
	@Delete("delete from recommend where article_id=#{id}")
	public int deleteRe(@Param("id")Long id);
	@Update("UPDATE article SET recommend = '0' WHERE id = #{id}")
	public int updater(@Param("id") Long id);
	
	//推荐文章
	@Insert("INSERT INTO blog.recommend (dev_user_id, article_id, backend_user_id, time)VALUES( #{dev_user_id}, #{article_id}, #{backend_user_id}, #{time})")
	public int addrecommend(@Param("dev_user_id") long dev_user_id,@Param("article_id") long article_id,@Param("backend_user_id") long backend_user_id,@Param("time") Date time);
	@Update("UPDATE article SET recommend = '1'WHERE id = #{id}")
	public int updatere(@Param("id") Long id);
}
